<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../css/mui.min.css" />

		<title></title>
	</head>
	<style>
		img {
			width: 10%;
			transform: translateY(6px);
		}
		
		span {
			margin-left: 5px;
		}
		
		a {
			color: black;
		}
	</style>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-back  mui-icon-backmui-pull-left"></a>
			<h1 class="mui-title">我的资料</h1>
		</header>
		<div class="mui-content">
			<div class="mui-card">
				<ul class="mui-table-view mui-table-view-chevron">
					<li class="mui-table-view-cell">
						<a class="mui-navigate-right" href="ziliao/select.html">
							<img src="../../images/mainInfo/jibenziliao.png" />
							<span>查看资料</span>
						</a>
					</li>
					<li class="mui-table-view-cell">
						<a class="mui-navigate-right" href="ziliao/update.html">
							<img src="../../images/mainInfo/b.png" />
							<span>编辑资料</span>
						</a>
					</li>
					<li class="mui-table-view-cell">
						<a class="mui-navigate-right" href="address/insertAddress.html">
							<img src="../../images/mainInfo/goodsPlace.png" />
							<span>添加收货地址</span>
						</a>
					</li>
					<li class="mui-table-view-cell">
						<a class="mui-navigate-right" href="address/updateAddress.html">
							<img src="../../images/mainInfo/goodsPlace.png" />
							<span>修改收货地址</span>
						</a>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-collapse-content">
							<form class="mui-input-group">
								<div class="mui-input-row">
									<label>旧密码</label>
									<input id="oldPassword" type="password" placeholder="旧密码">
								</div>
								<div class="mui-input-row">
									<label>新密码</label>
									<input id="newPassword" type="password" class="mui-input-clear" placeholder="新密码">
								</div>
								<div class="mui-input-row">
									<label>确认密码</label>
									<input id="enterNewPassword" type="password" class="mui-input-clear" placeholder="确认新密码">
								</div>
								<div class="mui-button-row">
									<button id="cancelBtn" class="mui-btn mui-btn-primary" type="button">取消</button>&nbsp;&nbsp;
									<button id="enterBtn" class="mui-btn mui-btn-primary" type="button">确认</button>
								</div>
							</form>
						</div>
					</li>
				</ul>
				<!--<li class="mui-table-view-cell mui-collapse">
					<a class="mui-navigate-right" href="#">联系信息</a>
					<ul id="OA_task_2" class="mui-table-view mui-table-view-chevron contact">
							<li class="mui-table-view-cell">
								<a class="mui-navigate-right" href="contact/insert.html">
									<img src="../../images/mainInfo/lianxiren.png" />
									<span>添加联系人</span>
								</a>
							</li>
							<li class="mui-table-view-cell">
								<a class="mui-navigate-right" href="contact/update.html">
									<img src="../../images/mainInfo/lianxiren.png" />
									<span>修改联系人</span>
								</a>
							</li>
							<li class="mui-table-view-cell">
								<a class="mui-navigate-right" href="contact/del.html">
									<img src="../../images/mainInfo/lianxiren.png" />
									<span>删除联系人</span>
								</a>
							</li>
						</ul>
				</li>-->
				<!--<li class="mui-table-view-cell mui-collapse">
						<a class="mui-navigate-right" href="#">绑定</a>
						<ul class="mui-table-view mui-table-view-chevron">
							<li class="mui-table-view-cell">
								<a class="mui-navigate-right" href="bingdin/bingdin.html">
									<img src="../../images/mainInfo/bangdingshouji.png" />
									<span>绑定手机</span>
								</a>
							</li>
							<li class="mui-table-view-cell">
								<a class="mui-navigate-right" href="bingdin/bingdin.html">
									<img src="../../images/mainInfo/bangdinyouxinag.png" />
									<span>绑定邮箱</span>
								</a>
							</li>
						</ul>
					</li>-->
				</ul>
			</div>
		</div>
	</body>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/myjs/localVarchar.js"></script>
	<script src="../../js/ipjs/ip.js"></script>
	<script src="../../js/constatnt/var.js"></script>
	<script>
		mui.init({
			swipeBack: true, //启用右滑关闭功能
			//预加载详情页
			preloadPages: [{
				url: 'contact/update.html',
				id: 'update'
			}, {
				url: "contact/del.html",
				id: "del"
			}, {
				url: "contact/insert.html",
				id: "insert"
			}],
			preloadLimit: 3
		});
		mui('.contact').on('tap', '.mui-navigate-right', function() {
			mui.openWindow({
				url: this.href,
				show: {
					autoShow: true, //页面loaded事件发生后自动显示，默认为true
					aniShow: "slide-in-right"
				},

			});
		});
		document.getElementById("cancelBtn").addEventListener('tap', function() {
			document.getElementById("oldPassword").value = "";
			document.getElementById("newPassword").value = "";
			document.getElementById("enterNewPassword").value = "";
		});
		document.getElementById("enterBtn").addEventListener('tap', function() {
			var editPassword = {
				newPassword: document.getElementById("newPassword").value,
				oldPassword: document.getElementById("oldPassword").value,
				phone: localStorage.getItem(LOCAL_USER_INFO)
			};
			if(editPassword.newPassword != editPassword.oldPassword) {
				document.getElementById("oldPassword").value = "";
				document.getElementById("newPassword").value = "";
				document.getElementById("enterNewPassword").value = "";
				mui.toast("两次输入的密码不一致");
			}
			if(editPassword.newPassword != "" &&
				editPassword.oldPassword != "" &&
				editPassword.phone != "") {
				mui.ajax(ip + '/userLogin/editPassword', {
					data: JSON.stringify(editPassword),
					dataType: 'json',
					type: 'post',
					timeout: 10000,
					headers: {
						'Content-Type': 'application/json'
					},
					success: function(data) {
						if(data.data.status == OPERATION_SUCCESS) {
							mui.toast(data.data.msg);
							alert("请您重新登录");
							plus.localStorage.removeItem(LOCAL_USER_INFO);
							window.location.href = "../../login.html";
						}else{
							mui.toast("密码不正确！");
						}
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						mui.toast("系统异常！");
					}
				});
			}
		});
	</script>

</html>